package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 媒体文件控制层
 *
 * @Author mr.lin
 * @Date 2025/1/26 18:08
 */
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;

    @PostMapping("/upload_picture")
    public ResponseResult upload(MultipartFile multipartFile) {
        return wmMaterialService.upload(multipartFile);
    }


    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto) {
        return wmMaterialService.imgList(dto);
    }

    @GetMapping("/del_picture/{id}")
    public ResponseResult deleteImg(@PathVariable("id") Integer id) {
        return wmMaterialService.deleteImg(id);
    }

    @GetMapping("/cancel_collect/{id}")
    public ResponseResult cancelCollect(@PathVariable("id") Integer id) {
        return wmMaterialService.cancelCollect(id);
    }

    @GetMapping("/collect/{id}")
    public ResponseResult collect(@PathVariable("id") Integer id) {
        return wmMaterialService.collect(id);
    }
}
